package presentation.models;

import java.awt.Color;
import java.awt.Component;

import javax.swing.DefaultListCellRenderer;
import javax.swing.JList;

import presentation.UIDirectory;

/**
 * cell renderer for the sub directories list 
 * (sets the way each element in the list is presented)
 */
public class SubDirsListCellRenderer extends DefaultListCellRenderer
{

	
	private static final long serialVersionUID = 1678055100257415135L ;
	
	private static Color _ALT_ROW = new Color(210, 240, 220);

	
	/**
	 * get the cell renderer of the sub directories list for a certain element
	 */
	@Override
	public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
		boolean cellHasFocus)
	{
		super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
		UIDirectory dir = (UIDirectory) value;
		setText(dir.getName());
		if (!isSelected && index % 2 == 0)
			setBackground(_ALT_ROW);
		return this;
	}

}
